package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.CacheUtils;
import com.ruoyi.system.domain.DataModuleType;
import com.ruoyi.system.mapper.SysModelManageMapper;
import com.ruoyi.system.service.ISysModelManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.ruoyi.system.utils.DictUtils.getCacheName;

@Service
public class SysModelManageServiceImpl implements ISysModelManageService {
    @Autowired
    private SysModelManageMapper modelManageMapper;

    @Override
    public List<DataModuleType> selectAllModelType(DataModuleType moduleType) {
        return modelManageMapper.selectAllModelType(moduleType);
    }

    @Override
    public int deleteModelTypeByIds(String[] ids) {
        int count = modelManageMapper.deleteModelTypeByIds(ids);
        if(count>0){//删除成功后清除缓存
            CacheUtils.removeAll(getCacheName());
        }
        return count;
    }

    @Override
    public int insertModelTypeInfo(DataModuleType moduleType) {
        return modelManageMapper.insertModelTypeInfo(moduleType);
    }

    @Override
    public DataModuleType selectModelTypeById(Integer id) {
        return modelManageMapper.selectModelTypeById(id);
    }

    @Override
    public int updateModelTypeById(DataModuleType modelType) {
        return modelManageMapper.updateModelTypeById(modelType);
    }

    @Override
    public boolean checkModelTypeNameUnique(DataModuleType modelType) {
        return modelManageMapper.checkModelTypeNameUnique(modelType)<=0;
    }
}
